home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / kernel / mach / sun4.md / machFPUGlue.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-07  |  3.4 KB  |  159 lines

  1. /* 
  2.  * machFPUGlue.c --
  3.  *
  4.  *    Routines that emulate the SunOS routines called by the
  5.  *    SunOS floating point simulator for SPARC.
  6.  *
  7.  * Copyright 1989 Regents of the University of California
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  */
  16.  
  17. #ifndef lint
  18. static char rcsid[] = "$Header: /cdrom/src/kernel/Cvsroot/kernel/mach/sun4.md/machFPUGlue.c,v 9.4 93/01/06 20:09:18 mgbaker Exp $ SPRITE (Berkeley)";
  19. #endif /* not lint */
  20.  
  21. /*
  22.  * Too much of the sun fpu stuff just won't lint.
  23.  */
  24. #ifndef lint
  25.  
  26. #ifndef NO_FLOATING_POINT
  27.  
  28. #include "sys/types.h"
  29. #include "fpu_simulator.h"
  30. #include "vm.h"
  31.  
  32.  
  33. /*
  34.  *----------------------------------------------------------------------
  35.  *
  36.  * fuword --
  37.  *
  38.  *    Read a word from the user's address space.
  39.  *
  40.  * Results:
  41.  *    The word read or -1 if read fails.
  42.  *
  43.  * Side effects:
  44.  *    None.
  45.  *
  46.  *----------------------------------------------------------------------
  47.  */
  48.  
  49. int
  50. fuword(address)
  51.     caddr_t address;
  52. {
  53.     ReturnStatus status;
  54.     int        value;
  55.     status = Vm_CopyIn(sizeof(int), (Address) address, (Address) &value);
  56.  
  57.      return (status == SUCCESS) ? value : -1;
  58.  
  59. }
  60.  
  61.  
  62. /*
  63.  *----------------------------------------------------------------------
  64.  *
  65.  * fubyte --
  66.  *
  67.  *    Read a byte from the user's address space.
  68.  *
  69.  * Results:
  70.  *    The byte read or -1 if read fails.
  71.  *
  72.  * Side effects:
  73.  *    None.
  74.  *
  75.  *----------------------------------------------------------------------
  76.  */
  77.  
  78. int
  79. fubyte(address)
  80.     caddr_t address;
  81. {
  82.     ReturnStatus status;
  83.     unsigned char    value;
  84.     status = Vm_CopyIn(sizeof(char), (Address) address, (Address) &value);
  85.  
  86.      return (status == SUCCESS) ? value : -1;
  87.  
  88. }
  89.  
  90.  
  91. /*
  92.  *----------------------------------------------------------------------
  93.  *
  94.  * suword --
  95.  *
  96.  *    Store a word into the user's address space.
  97.  *
  98.  * Results:
  99.  *    The 0 if SUCCESS or -1 if write fails.
  100.  *
  101.  * Side effects:
  102.  *    None.
  103.  *
  104.  *----------------------------------------------------------------------
  105.  */
  106.  
  107. int
  108. suword(address,value)
  109.     caddr_t address;
  110.     int    value;
  111. {
  112.     ReturnStatus status;
  113.     status = Vm_CopyOut(sizeof(int), (Address) &value, (Address) address);
  114.  
  115.      return (status == SUCCESS) ? 0 : -1;
  116.  
  117. }
  118.  
  119. #include <sun4/fpu/globals.h>
  120.  
  121. void
  122. MachFPU_Emulate(processID, instAddr, userRegsPtr, curWinPtr)
  123.     int        processID;
  124.     Address    instAddr;
  125.     Mach_RegState     *userRegsPtr;
  126.     Mach_RegWindow    *curWinPtr;
  127. {
  128.     enum ftt_type result;
  129.  
  130.     fptrapaddr = (char *) instAddr;    /* bad inst addr in case we trap */
  131.     _fp_current_pfregs = userRegsPtr;
  132.     result = fpu_simulator(instAddr, (fsr_type *) & (userRegsPtr->fsr));
  133.     switch (result) {
  134.     case ftt_none:
  135.     break;
  136.     case ftt_ieee:
  137.     (void) Sig_Send(SIG_ARITH_FAULT, SIG_ILL_INST_CODE, processID, FALSE,
  138.         (Address)0);
  139.     break;
  140.     case ftt_unimplemented:
  141.     (void) Sig_Send(SIG_ILL_INST, SIG_ILL_INST_CODE, processID, FALSE,
  142.         (Address)0);
  143.     break;
  144.     case ftt_alignment:
  145.     (void) Sig_Send(SIG_ADDR_FAULT, SIG_ADDR_ERROR, processID,FALSE,
  146.         (Address)0);
  147.     break;
  148.     case ftt_fault:
  149.     (void) Sig_Send(SIG_ADDR_FAULT, SIG_ACCESS_VIOL, processID, FALSE,
  150.         (Address)0);
  151.     case ftt_7:
  152.     default:
  153.     break;
  154.     }
  155. }
  156. #endif /* NO_FLOATING_POINT */
  157.  
  158. #endif /* lint */
  159.